distribute allows to specify the distribution pattern, or a timesheet string, which controls to which zones of a section the values are distributed. If the distribution pattern is '(= x) then the first zone will be left empty, second is filled with symbols, 3rd is empty, the 4th is filled., etc.
To control exactly how the distribution will happen, use a pattern of the same length than there are zones for the section. If the distribution pattern is shorter than there are zones in this section the distribution pattern is repeated. The distribution can be realized in one of the following ways, :once, :repeat and :restart, which work in the same way as in skip-zone.
Distribution pattern is the first parameter. The range is the second. :all guides the distribution to concentrate on all the zones of the section. To specify the start and end zones give the start and end zones in a list. If you are not sure how long the section is use :end keyword to indicate that distribution is performed to the end of the section. The distribution patterns is in effect at the beginning of the range.
The symbol pattern is always a flat, an ordinary symbol pattern. Use :collapse keyword within same-as, or collapse function to flatten zoned symbol patterns. Study the following examples.
(distribute '(= x) :all :restart
(symbol-transpose 2 theme)
'(1/4 1/8 1/8)
'(1/2 1/2 1/2 1/2))
--> (nil (c d e) nil (c d))
(distribute '(x) '(1 :end) :restart
(symbol-transpose 2 theme)
'(1/4 1/8 1/8)
'(1/2 1/2 1/2 1/2 1/2 1/2 1/2 1/2))
--> ((c d e) (c d e) (c d e) (c d e) (c d e) (c d) (c d e) (c d e))
This shows you how to distribute values to the 1st and 2nd zone of the section, and another values to the 3rd and 4th zone, each with its own distribution pattern and type.
(append (distribute '(= x) '(1 2) :repeat
'(a b)
'(1/4 1/8 1/8)
'(1/2 1/2 1/2 1/2))
(distribute '(x =) '(3 4) :once
'(x y)
'(1/4 1/8 1/8)
'(1/2 1/2 1/2 1/2)))
--> (nil (a b a) (x y =) nil)
In use within a context you don't have to include the section length and zone values, since distribute automatically adjusts to the environment. If you use it alone to break up the source pattern into subpatterns you have to specify these items. Within def-class you would call the above example as: